package com.xx.springboot.designPattern.DecoratorMode;/**
 * Created by xiaoxiunique on 2018-11-14.
 */

import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;

/**
 * <p>
 * TODO:
 * </p>
 *
 * @author hcg
 * @date 2018-11-14 10:49
 * @className UpperFirstWordInputStream
 */
public class UpperFirstWordInputStream extends FilterInputStream {
    private int cBefore = 32;

    public UpperFirstWordInputStream(InputStream in) {
        super(in);
    }

    @Override
    public int read() throws IOException {
        int c = super.read();
        if(cBefore == 32) {
            cBefore = c;
            return c == -1 ? c : Character.toUpperCase(c);
        }else {
            cBefore = c;
            return c;
        }
    }
}
